# encoding=utf8
"""
yield生成器（使用时候生成，占用更小的内存）
"""
def createGenerator():
    mylist = range(3)
    for i in mylist:
        yield i * i
        # print  (u'i=%s' % i)


# 执行代码
if __name__ == '__main__':
    mygenerator = createGenerator()
    for i in mygenerator:
        print(i)
        break
    # 第二遍
    for i in mygenerator:
        print(i)
        break
    print("////////第三遍/////////")
    for i in mygenerator:
        print(i)
    print("////////第4遍没有了/////////")
    for i in mygenerator:
        print(i)